/*! \file MemoryMappedFile.h
 *	\brief <write description for MemoryMappedFile.h>
 *
 *	created:	2010/11/23
 *	created:	23:11:2010   10:12
 *	filename: 	C:\src\tactics-engine\libs\io\MemoryMappedFile.h
 *	file path:	C:\src\tactics-engine\libs\io
 *	file base:	MemoryMappedFile
 *	file ext:	h
 *	author:		Vitalii Trubchaninov
 *				vitalii.trubchaninov@ubisoft.com
 */

#ifndef _io_MEMORYMAPPEDFILE_H_
#define _io_MEMORYMAPPEDFILE_H_

#pragma once

#include "core/String.h"
#include "io/MemoryMappedFileTypes.h"

#if defined(TT_WIN32)
#	include "io/win32/MemoryMappedFile_win32.h"
#elif defined(TT_UNIX)
#	include "io/unix/MemoryMappedFile_unix.h"
#else
#	error "Unsupported platform."
#endif //defined(TT_WIN32)

namespace tt{
namespace io{

class MemoryMappedFile
{
public:
	explicit MemoryMappedFile();
	explicit MemoryMappedFile(const std::wstring& fileMappingName);
	~MemoryMappedFile();

	bool Open(const std::wstring& fileName, MemoryMappedFileMode mode = MemoryMappedFileMode_READONLY);
	void Close();

	bool Writeable() const;

	Size GetSize() const;

	const void* GetData() const;

	template<typename Type>
	const Type* GetData() const;

private:
	MemoryMappedFilePS m_ps;
};

} //namespace io
} //namespace tt
#include "MemoryMappedFile.inl"

#endif //_io_MEMORYMAPPEDFILE_H_